//
//  JSMeViewController.m
//  NiubilityProject
//
//  Created by Apple on 2017/11/23.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "JSMeViewController.h"
#import "JSMetableViewCell.h"
#import "JSMeTableHeaderView.h"
#import "JSMetableViewUserInfoCell.h"
#import "JSMeAttontionFansCell.h"
#import "JSMeUserInfoVC.h"
#import "JSFeedbackViewController.h"
#import "JSSettingViewController.h"
@interface JSMeViewController ()



@end

@implementation JSMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSDictionary *rootVCs = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"meItemInfo" ofType:@"plist"]];
    NSArray *vcArray = rootVCs[@"viewControllrs"];
    [self.dataSource addObjectsFromArray:[JSMeInfo mj_objectArrayWithKeyValuesArray:vcArray]];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 0) {
        if (indexPath.row == 0) { //MARK:个人信息
            JSMeUserInfoVC *vc = [[JSMeUserInfoVC alloc] init];
            JS_VC_PUSHVC_ANIMATION(YES);
        }
    }else{
        JSMeInfo *vcInfo = self.dataSource[indexPath.row];
        NSString *className = vcInfo.className;
        NSString *locaKey   = vcInfo.locaKey;
        UIViewController *vc = [[NSClassFromString(className) alloc] init];
        vc.title = JSLocalizedString(locaKey);
        JS_VC_PUSHVC_ANIMATION(YES);
    }
}








- (void)didInitialized{
    [super didInitialized];
    self.view.backgroundColor = JS_colorWithHex(0xe7e7e7);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section) {
        return self.dataSource.count;
    }
     return 2;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    JS_WeakSelf(self)
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            JSMetableViewUserInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"infoid"];
            if (!cell) {
                cell = [[JSMetableViewUserInfoCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"infoid"];
                cell.accessoryType = QMUIStaticTableViewCellAccessoryTypeDisclosureIndicator;
            }
            JS_WeakSelf(cell)
            [cell.imageView setImageWithURL:[NSURL URLWithString:userManager.curUserInfo.avatar] placeholder:UIImageMake(@"defaultUserImage") options:YYWebImageOptionUseNSURLCache completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
                weakcell.imageView.image = [[image imageByResizeToSize:CGSizeMake(kRealValue(55), kRealValue(55))] imageByRoundCornerRadius:25];
            }];
            cell.textLabel.text = userManager.curUserInfo.username;
            cell.detailTextLabel.text = @"test";
            return cell;
        }else if(indexPath.row == 1){
            JSMeAttontionFansCell *cell = [tableView dequeueReusableCellWithIdentifier:@"attentionFans"];
            if (!cell) {
                cell = [[JSMeAttontionFansCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"attentionFans"];
            }
#pragma mark -------------粉丝 关注 点击------------
            [cell setBtnClick:^(AttontionFansClick style) {
                /// other..
                JSLog(@"%zd",style);
                
            }];
            return cell;
        }
    }
    JSMetableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[JSMetableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.accessoryType = QMUIStaticTableViewCellAccessoryTypeDisclosureIndicator;
    }
    JSMeInfo *info = self.dataSource[indexPath.row];
    cell.imageView.image = UIImageMake(info.imageStr);
    cell.textLabel.text  = JSLocalizedString(info.locaKey);
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row) {
            return kRealValue(60);
        }
        return kRealValue(88);
    }
    return kRealValue(50);
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section) {
        return 0.0001;
    }
    return kRealValue(10);
}
- (void)setNavigationItemsIsInEditMode:(BOOL)isInEditMode animated:(BOOL)animated{
    [super setNavigationItemsIsInEditMode:isInEditMode animated:NO];
    self.title = JSLocalizedString(@"tabBarTitle4");
}
- (void)initTableView{
    [super initTableView];
    self.tableView.mj_footer = nil;
    self.tableView.mj_header = nil;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = [UIColor clearColor];
}
-(UIImage *)navigationBarShadowImage{
    return [UIImage qmui_imageWithColor:JS_colorWithHex(0xe7e7e7) size:CGSizeMake(SCREEN_WIDTH, flatf(1)) cornerRadius:0];
}


@end
@implementation JSMeInfo

@end


